﻿// -----------------------------------------------------------------------
// <copyright file="RescheduleLog_DAL.cs" company="">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace PMSGSC.DAL
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public class RescheduleLog_DAL :BaseDAL
    {
        // Lấy tất cả RescheduleLog
        public static List<RescheduleLog> GetAll(int shipID)
        {
            DB.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, DB.RescheduleLogs);
            return DB.RescheduleLogs.Where(n=>n.WorkOrder.Equipment.Ship_ID == shipID).ToList();
        }
        // Lấy RescheduleLog theo Id
        public static RescheduleLog GetDataById(int id)
        {
            return DB.RescheduleLogs.Where(m => m.RescheduleLog_ID == id).FirstOrDefault();
        }
        //Thêm một RescheduleLog
        public static bool Insert(RescheduleLog RescheduleLog)
        {
            try
            {
                DB.RescheduleLogs.InsertOnSubmit(RescheduleLog);
                DB.SubmitChanges();
                return true;
            }
            catch
            {
                return false;
            }

        }
        // Xóa một RescheduleLog
        public static bool Delete(RescheduleLog RescheduleLog)
        {
            try
            {
                DB.RescheduleLogs.DeleteOnSubmit(RescheduleLog);
                DB.SubmitChanges();
                return true;
            }
            catch
            {
                return false;
            }

        }
        // Cập nhật RescheduleLog
        public static bool Update(RescheduleLog RescheduleLog)
        {
            try
            {
                //RescheduleLog objRescheduleLog = GetDataById(RescheduleLog.RescheduleLog_ID);
                //objRescheduleLog.CodeRescheduleLog = RescheduleLog.CodeRescheduleLog;
                //objRescheduleLog.NameRescheduleLog = RescheduleLog.NameRescheduleLog;
                //objRescheduleLog.Address = RescheduleLog.Address;
                //objRescheduleLog.Tell = RescheduleLog.Tell;
                //objRescheduleLog.Email = RescheduleLog.Email;
                //objRescheduleLog.ContactPerson = RescheduleLog.ContactPerson;
                //objRescheduleLog.Fax = RescheduleLog.Fax;
                //objRescheduleLog.Note = RescheduleLog.Note;
                DB.SubmitChanges();
                return true;
            }
            catch
            {
                return false;
            }

        }
    }
}
